
{include file="public/top" /}

<body class="layui-anim layui-anim-up">

<div class="x-body">
    <div class="layui-row clear pagesa">
        <p class="fl">>网站访问明细</p>
    </div>
    <div class="layui-row" style="margin: 10px 0 -10px 0">
        <xblock>

            <div  style="line-height:40px">
                总访问量：<?php echo $params['total'];?>，
                今日访问量：<?php echo $params['day'];?>，
                昨日访问量：<?php echo $params['yesterday'];?>

                【本周访问量：<?php echo $params['week'];?>，
                上周访问量：<?php echo $params['last_week'];?>，
                对比上周访问：
                <?php if($params['contrast_week'] > 0):?>
                <span style="color: red;font-weight: bold">上升</span>
                <?php elseif($params['contrast_week'] == 0):?>
                <span style="color: #FFB800;font-weight: bold">持平</span>
                <?php else:?>
                <span style="color: #5FB878;font-weight: bold">下降</span>
                <?php endif;?>
                <?php echo $params['contrast_week'];?>%】
                【本月访问量：<?php echo $params['month'];?>，
                上月访问量：<?php echo $params['last_month'];?>，
                对比上月访问：
                <?php if($params['contrast_month'] > 0):?>
                <span style="color: red;font-weight: bold">上升</span>
                <?php elseif($params['contrast_month'] == 0):?>
                <span style="color: #FFB800;font-weight: bold">持平</span>
                <?php else:?>
                <span style="color: #5FB878;font-weight: bold">下降</span>
                <?php endif;?>
                <?php echo $params['contrast_month'];?>%】


            </div>

        </xblock>
        <form class="layui-form layui-col-md12 x-so">
            <!--分开-->
            <button class="layui-btn layui-btn-danger fr" id="del" type="button"><i class="layui-icon ">&#xe640;</i>清除访问明细</button>

        </form>
    </div>

    <table class="" lay-filter="test" id="table" ></table>

    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
</div>

<script>
    //接口地址
    var listurl = '/admin/statistics/accessip';
    var delurl = '/admin/statistics/removeaccessip';


    layui.use('table', function(){
        var table = layui.table;

        //初始化表格
        table.render({
            elem: '#table'
            ,height: 'full-140'
            ,method:'post'
            ,url: listurl //数据接口
            ,page: true //开启分页
            ,limit:50
            ,limits:[50, 100, 300]
            ,id:'idTest'
            ,cols: [[ //表头
                {field: 'id',width:40,title: 'ID', fixed: 'left'}
                ,{field: 'ip', title: '访问IP',width:'150'}
                ,{field: 'city', title: '访问来源',width:'200'}
                ,{field: 'browser', title: '访问浏览器',width:'200'}
                ,{field: 'agent', title: '访问信息',width:'700'}
                ,{field: 'create_time', title: '访问时间'}
            ]]
        });

        //批量删除
        $('#del').click(function () {
            layer.confirm('真的清除访问明细吗？', function(index){
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: delurl,
                    data: {'token':'fasdfasdfadsf'},
                    success: function (res) {
                        layer.msg('访问明细清除成功！');
                        table.reload('idTest', {
                            url: listurl
                            ,where: {} //设定异步数据接口的额外参数
                            //,height: 300
                        });
                    }
                });

            });
        });

    });




</script>

</body>

</html>
